<?php
/**
 * @file : wapinfohistory.php
 * @author : zhouzhe@haibao.com
 * @date : 2015-6-9 15:02:22
 */
namespace haibao\cms\data;

class WapInfoHistory extends \haibao\cms\data\BaseMysql{

    public function __construct(){
        parent::__construct('\haibao\cms\model\data\WapInfoHistory');
    }

	public function getWapInfoHistoryList($filter){
		return parent::getAll($filter);
	}
	
	public function addWapInfoHistoryModel($Id,$model=array(),$operType=\haibao\cms\model\data\WapInfoHistory::OPER_TYPE_EDIT){
		$historyModel = $this->getHistoryModelById($Id, $model,$operType);
		$this->add($historyModel);
	}
	
	private function getHistoryModelById($Id,$model,$operType){
		$historyModel = new \haibao\cms\model\data\WapInfoHistory();
	
		$historyModel->CreateBy = self::getCurrentUser ()->Id;
		$historyModel->CreateTime = new \DateTime();
		$wapInfoData = new \haibao\cms\data\WapInfo();
		$wapInfo = $wapInfoData->getOneById($Id);
	
		$historyModel->Title = $model['Title']?$model['Title']:$wapInfo->Title;
		$historyModel->IndexTop = $model['IndexTop']?$model['IndexTop']:$wapInfo->IndexTop;
		$historyModel->ChannelTop = $model['ChannelTop']?$model['ChannelTop']:$wapInfo->ChannelTop;
		$historyModel->PublishTime = $model['PublishTime']?$model['PublishTime']:$wapInfo->PublishTime;;
		$historyModel->InfoId = $wapInfo->InfoId;
		$historyModel->InfoType = $wapInfo->InfoType;
		$historyModel->OperType = $operType;
		return $historyModel;
	}
}
